<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //1.apaply(调用者,数组)
        function show(){
            console.log(this);
        }
        var user={
            name:"tom"
        };
        //apply方法中将基本数据类型转换成引用数据类型 "abc" => new String("abc")
        // show.apply(user);
        // show.apply(1234);
        // show.apply(false);

        function show2(a,b,c){
            console.log(this);
            console.log(a);
            console.log(b);
            console.log(c);
        }

        // 函数.call(调用者,参数);
        show2.call(user,"参数1","参数2","参数3");

        // apply(调用者,数组)
        // 在apply中第二个参数数组可以完成自行的循环展开，将数组中的元素对应赋值给函数的形参
        // show2.apply(user,["参数1","参数2","参数3"]);

        var arrays=[2,1,23,89,34,8];
        var arrays2=[2,-1,23,89,34,890];
        // console.log( Math.max(2,1,23,89,34,8));
        // console.log( Math.min(2,1,23,89,34,8));
        console.log(Math.max.apply(arrays,arrays));
        console.log(Math.min.apply(arrays,arrays,arrays2));




        


    </script>
</head>
<body>
    
</body>
</html>